Extracts files from a spanned zip file specifying the callback method called when requesting a new disk, providing a decryption password and specifying whether existing files will be overwritten and if the directory structure will be restored.
'Usage
Dim zipFileName As String
Dim destinationFolder As String
Dim decryptionPassword As String
Dim replaceExistingFiles As Boolean
Dim recursive As Boolean
Dim preservePaths As Boolean
Dim diskRequiredCallback As QuickZip.DiskRequiredCallback
Dim userParams As Object
Dim filesToUnzip() As StringQuickZip.Unzip(zipFileName, destinationFolder, decryptionPassword, replaceExistingFiles, recursive, preservePaths, diskRequiredCallback, userParams, filesToUnzip)
Parameters
zipFileName
The fully-qualified path and name of the zip file.
destinationFolder
The destination folder to where the files will be extracted.
decryptionPassword
The password that will be used to decrypt the files.
replaceExistingFiles
Boolean value indicating if existing files should be overwritten.
recursive
Boolean value indicating if files contained within sub-folders should be extracted from the zip file.
preservePaths
Boolean value indicating if the directory structure should be preserved in the destination folder.
diskRequiredCallback
The callback method called whenever the DiskRequired event is triggered.
userParams
Opaque data which will be passed back to the callback method.
filesToUnzip
The files to extract from zipFileName. Cannot be a null reference (Nothing in Visual Basic).
Remarks
Zip files are case sensitive therefore the string passed in the filesToUnzip parameter, will be used "as-is".
For example, if a zip file contains a file named "FILE.TXT" and "file.txt" is passed to the filesToUnzip parameter, "FILE.TXT" will not be extracted.
If the destination item(s) exists, the attributes and dates of the original item(s) are not applied to the destination item(s).
Handling paths
When extracting files from within a zip file, the directory structure can be restored fully or partially or it can be omitted altogether.
If the preservePaths parameter of the Unzip method is set to false, the files specified in the filesToUnzip parameter will be restored directly into the root of the destination folder without recreating the directory structure.
For example, if you have a zip file containing files in the "folder1" subfolder and files in the "folder1\folder2" subfolder, the following code will unzip all files right into "c:\temp", without creating any subfolders:
If the preservePaths parameter is set to true, the part of the path that is explicitly included in the filesToUnzip parameter will not be restored into the destination folder.
For example, for the same zip file as above, the following code will create the folder "folder2" into the "c:\temp" destination folder. Files that were in the "folder1" subfolder in the zip will be unzipped directly into the root of "c:\temp", and files that were in "folder1\folder2" will be unzipped into "c:\temp\folder2":
QuickZip.Unzip( "a:\test.zip", "d:\", string.Empty, true, true, false, _
New QuickZip.DiskRequiredCallback(AddressOfMe.QuickDiskRequired), _
Nothing, "*" )
' This method will handle the DiskRequired events that are raised when creating
' spanned or split zip files.
PrivateFunction QuickDiskRequired(ByVal zipFile AsString, ByVal diskNumber AsInteger, _
ByVal userData AsObject) AsBooleanIf (MessageBox.Show("Disk #" + diskNumber.ToString() + _
" is required.", "Disk Required", _
MessageBoxButtons.OKCancel) = DialogResult.OK) ThenReturnTrueElseReturnFalseEndIfEnd Function
QuickZip.Unzip( @"a:\test.zip", @"d:\", string.Empty, true, true,
false, new QuickZip.DiskRequiredCallback( this.QuickDiskRequired ),
null, "*" );
// This method will handle the DiskRequired events that are raised when creating
// spanned or split zip files.
privatebool QuickDiskRequired( string zipFile, int diskNumber, object userData )
{
if( MessageBox.Show( "Disk #" + diskNumber.ToString() + " is required.",
"Disk Required", MessageBoxButtons.OKCancel ) == DialogResult.OK )
returntrue; elsereturnfalse;
}
Requirements
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2